package com.css.fxfzysx.modules.vabStructure.controller;

import com.css.fxfzysx.base.response.RestResponse;
import com.css.fxfzysx.modules.cztDataMange.entity.CbhdInfoEntity;
import com.css.fxfzysx.modules.vabStructure.entity.CztBuildingMatrixEntity;
import com.css.fxfzysx.modules.vabStructure.param.BuildingStructureParam;
import com.css.fxfzysx.modules.vabStructure.param.CustomVulnerabilityParam;
import com.css.fxfzysx.modules.vabStructure.service.SvAnalysisService;
import com.css.fxfzysx.modules.vabStructure.vo.GenerateVulnerabilityMatrixVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;

/**
 * 统计易损性分析
 */
@RestController
@RequestMapping("svAnalysis")
public class SvAnalysisController {

    @Autowired
    private SvAnalysisService svAnalysisService;


    /**
     * 生成易损性矩阵
     * @param ids
     * @return
     */
    @GetMapping("generateVulnerabilityMatrix")
    public RestResponse generateVulnerabilityMatrix(String ids,Integer type){
        return svAnalysisService.generateVulnerabilityMatrix(ids,type);
    }

    /**
     * 建筑物震害信息分页查询
     */
    @GetMapping("queryBuildings")
    public RestResponse queryBuildings(CbhdInfoEntity cbhdInfoEntity, HttpServletRequest request) {
        return svAnalysisService.queryBuildings(cbhdInfoEntity, request);
    }

    /**
     * 易损性矩阵导出
     */
    @PostMapping("exportMatrix")
    public void exportMatrix(@RequestParam("ids") String ids,
                             HttpServletResponse response,
                             @RequestParam("type") Integer type){
        svAnalysisService.exportMatrix(ids, response,type);
    }

    /**
     * 建筑物数据查询   为产品信息提供数据
     */
    @GetMapping("queryBuildingStructure")
    public RestResponse queryBuilding(BuildingStructureParam buildingStructureParam){
        return svAnalysisService.queryBuildingStructure(buildingStructureParam);
    }


    /**
     * 预测数据
     */
    @GetMapping("queryPredictiveData")
    public RestResponse queryPredictiveData(CbhdInfoEntity cbhdInfoEntity, HttpServletRequest request){
        return svAnalysisService.queryPredictiveData(cbhdInfoEntity,request);
    }

    /**
     * 筛选数据
     */
    @GetMapping("queryFilterData")
    public RestResponse queryFilterData(CbhdInfoEntity cbhdInfoEntity, HttpServletRequest request){
        return svAnalysisService.queryFilterData(cbhdInfoEntity,request);
    }

    /**
     * 查询是否是管理员
     */
    @GetMapping("queryAdmin")
    public boolean queryAdmin(){
        return svAnalysisService.queryAdmin();
    }


    /**
     * 生成的易损性矩阵分页查询
     */
    @GetMapping("getVulnerabilityMatrix")
    public RestResponse getVulnerabilityMatrix(CztBuildingMatrixEntity cztBuildingMatrixEntity, HttpServletRequest request) {
        return svAnalysisService.getVulnerabilityMatrix(cztBuildingMatrixEntity, request);
    }

    /**
     * 生成的易损性矩阵   查看矩阵
     */
    @GetMapping("matrix")
    public RestResponse matrix(String matrixId) {
        return svAnalysisService.matrix(matrixId);
    }

    /**
     * 生成的易损性矩阵导出
     */
    @PostMapping("generatedExportMatrix")
    public void generatedExportMatrix(HttpServletResponse response,
                             @RequestParam("matrixId") String matrixId){
        svAnalysisService.generatedExportMatrix(response,matrixId);
    }

    /**
     * 根据id查询详情
     */
    @GetMapping("getDataById")
    public RestResponse getDataById(String dataId,String dataType,String number) {
        return svAnalysisService.getDataById(dataId,dataType,number);
    }

    /**
     * 移入，移出基础库
     */
    @GetMapping("moveBasicLibrary")
    public RestResponse moveBasicLibrary(CustomVulnerabilityParam param) {
        return svAnalysisService.moveBasicLibrary(param);
    }

    /**
     * 删除
     * @param ids
     * @return
     */
    @GetMapping("deleteBasicLibrary")
    public RestResponse deleteBasicLibrary(String ids) {
        return svAnalysisService.deleteBasicLibrary(ids);
    }

    /**
     * 重新计算
     * @param
     * @return
     */
    @PostMapping("recalculate")
    public RestResponse recalculate(@RequestBody HashMap<String,String> map) {
        return svAnalysisService.recalculate(map);
    }
}
